import Fullscreen from "@iconify-icons/ri/fullscreen-fill";
import CloseOtherTags from "@iconify-icons/ri/text-spacing";
import CloseRightTags from "@iconify-icons/ri/text-direction-l";
import CloseLeftTags from "@iconify-icons/ri/text-direction-r";
import RefreshRight from "@iconify-icons/ep/refresh-right";
import Close from "@iconify-icons/ep/close";
import { tagsViewsType } from "./type";
const refresh = (show = true) => {
  return {
    icon: RefreshRight,
    text: "重新加载",
    divided: false,
    disabled: false,
    show: show
  };
};
const close = (num: number, noZore = true) => {
  return [
    {
      icon: Close,
      text: "关闭当前标签页",
      divided: false,
      disabled: num > 1 ? false : true,
      show: noZore
    },
    {
      icon: CloseLeftTags,
      text: "关闭左侧标签页",
      divided: true,
      disabled: num > 1 ? false : true,
      show: noZore ? (num > 1 ? true : false) : false
    },
    {
      icon: CloseRightTags,
      text: "关闭右侧标签页",
      divided: false,
      disabled: num > 1 ? false : true,
      show: num > 1 ? true : false
    },
    {
      icon: CloseOtherTags,
      text: "关闭其他标签页",
      divided: true,
      disabled: num > 2 ? false : true,
      show: num > 1 ? true : false
    }
  ];
};

const fullScreen = () => {
  return [
    {
      icon: Fullscreen,
      text: "内容区全屏",
      divided: false,
      disabled: false,
      show: true
    },
    {
      icon: Fullscreen,
      text: "整体页面全屏",
      divided: true,
      disabled: false,
      show: true
    }
  ];
};
export const getTagsViews = (
  num: number,
  index: number,
  select = false
): tagsViewsType[] => {
  const record = [...close(num, index !== 0)];
  record.unshift(refresh(select || index === -1));
  if (index === -1) {
    return [refresh(), ...fullScreen()];
  }
  return record;
};
